package com.hc.conferencecheck.controller;

import com.hc.conferencecheck.entity.ResultMsg;
import com.hc.conferencecheck.service.ConventionerService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 与会者controller
 */
@RestController
@RequestMapping("/conventionerController")
public class ConventionerController {
    @Resource
    private ConventionerService conventionerServiceImpl;

    /**
     * 查询所有已注册用户
     */
    @RequestMapping("/selectAllConventioners")
    public ResultMsg selectAllConventioners(@RequestBody Map<String, Object> params) {
        ResultMsg resultMsg = conventionerServiceImpl.selectAllConventioners(params);
        return resultMsg;
    }

    /**
     * 修改密码接口
     */
    @RequestMapping("/editPassWord")
    public ResultMsg editPassWord(@RequestBody Map<String, Object> params, HttpServletRequest request) {
        ResultMsg resultMsg = conventionerServiceImpl.editPassWord(params, request);
        return resultMsg;
    }

    /**
     * 与会者登录接口
     */
    @RequestMapping("/login")
    public ResultMsg login(@RequestBody Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) {
        ResultMsg resultMsg = conventionerServiceImpl.login(params, request, response);
        return resultMsg;
    }

    /**
     * 与会者注册接口
     */
    @RequestMapping("/register")
    public ResultMsg register(@RequestBody Map<String, Object> params, HttpServletRequest request) {
        ResultMsg resultMsg = conventionerServiceImpl.register(params, request);
        return resultMsg;
    }

    /**
     * 校验手机号，手机号是否符合格式，手机号是否已经注册
     */
    @RequestMapping("/matchPhoneNumber")
    public ResultMsg matchPhoneNumber(@RequestBody Map<String, Object> params) {
        ResultMsg resultMsg = conventionerServiceImpl.matchPhoneNumber(params);
        return resultMsg;
    }
}
